#include <iostream>

#include "sorted_array.h"

using namespace std;

//+-----------------------------------------------------
//| Module:      main
//| Description: Test the array module
//+-----------------------------------------------------
int main()
{
  const int SIZE = 1024;
  float array[SIZE];
  int size_used = 0;
  
  // The following loop produce all numbers [ 1 - SIZE ]. This series
  // will cause inserts to happen several times at all positions,
  // including the important corner cases first, internal and last as
  // long as SIZE is a poer of two
  for (int i = 0; i < SIZE; ++i)
  {
    int j = ((i+SIZE/2)*7)%SIZE + 1;
    array_insert(array, size_used, j);
  }

  cout << "Array after all insertions: " << endl;
  array_print(cout, array, size_used);
  
  float copy[SIZE];
  int copy_size_used = 0;
  array_copy(copy, array, copy_size_used, size_used);
  
  // Same number generation loop as before
  for (int i = 0; i < SIZE; ++i)
  {
    int j = ((i+SIZE/2)*7)%SIZE + 1;
    array_remove(array, size_used, array_find(array, size_used, j));
  }
  
  cout << "Array after all removals: " << endl;
  array_print(cout, array, size_used);
  

  cout << "Copy before of data before all removals: " << endl;
  array_print(cout, copy, copy_size_used);
  
  return 0;
}
